<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>25-自定义局部指令用法</title>
    <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
    <style></style>
  </head>
  <body>
    <div id="app">
      <input type="text" v-color="msg" />
      <input type="text" v-focus />
    </div>
    <script>
      var vm = new Vue({
        el: '#app',
        data: {
          msg: {
            color: 'skyblue',
          },
        },
        methods: {},
        directives: {
          color: {
            bind: function (el, bind) {
              el.style.backgroundColor = bind.value.color;
            },
          },
          focus: {
            inserted: function (el) {
              el.focus();
            },
          },
        },
      });
    </script>
  </body>
</html>
